package com.heima.user.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.user.service.ApUserChannelService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/api/v1/channel")
public class ApUserChannelController {
    @Resource
    private ApUserChannelService apUserChannelService;
    /**
     * 获取用户频道列表
     * @param userId
     * @return
     */

    @GetMapping("/isSub")
    public ResponseResult isSub(@RequestParam Integer userId, @RequestParam Integer channelId) {
        return apUserChannelService.isSub(userId, channelId);
    }
    /**
     * 频道订阅或取消订阅
     * @param userId
     * @param channelId
     * @param isSub
     * @return
     */

    @PostMapping("/sub")
    public ResponseResult sub(@RequestParam Integer userId, @RequestParam Integer channelId,@RequestParam Boolean isSub) {
        return apUserChannelService.sub(userId, channelId,isSub);
    }
    /**
     * 获取用户已订阅频道列表
     * @param userId 用户ID
     * @return 已订阅频道列表
     */
    @GetMapping("/user/{userId}")
    public ResponseResult getUserSubChannels(@PathVariable Integer userId) {
        return apUserChannelService.getUserSubChannels(userId);
    }

}
